import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.net.Socket;

public class Client implements Runnable {  
	
	Callback c;
	FileObject fo;
	int port;
	String ip;
	
	public Client(Callback c, FileObject fo, String ip, int port){
		this.c = c;
		this.fo = fo;
		this.port = port;
		this.ip = ip;
	}
	
	@Override
	public void run() {
		
		try{  
			Socket s = new Socket(this.ip,this.port);  
			OutputStream os = s.getOutputStream();  
			ObjectOutputStream oos = new ObjectOutputStream(os);  
			oos.writeObject(this.fo);
			oos.close();  
			os.close();
			s.close();
			
			this.c.callback();
		}
		catch(Exception e){System.out.println(e);}  
		
	}
}  